
// const BASE_URL = "" //线下
const BASE_URL = "http://h5.jingluogo.cn"  //线上
const request = (config) => {
	if(!config.noloading){
		uni.showLoading({
			title:'正在加载'
		})
	}
	return new Promise((resolve, reject) => {
		uni.request({
			url: BASE_URL + config.url,
			method: config.method || 'GET',
			data: config.data || {},
			header: { // "Bearer " +  Authorization
				"Authorization": uni.getStorageSync('ytbtoken') || ""
			},
			success: (res) => {
				uni.hideLoading()
				if (res.data.msg=='令牌不能为空') {
					uni.reLaunch({
						url: '/pages/index/login'
					})
				}
				
				resolve(res)
			},
			fail: (err) => {
				// uni.hideLoading()
				reject(err)
			}
		})
	})
};
// 上传

export {
	request,
	BASE_URL
};
